//注册用户数据库操作
package mymail;
import db.db_connection;

import java.security.NoSuchAlgorithmException;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DaoRegister {
	private String username;
	private String password;
	public DaoRegister(String Username,String Password){
		username=Username;
		password=Password;
	}
	static String sql = null;
    static db_connection db1 = null;
    static ResultSet ret = null;
	
	public boolean add(String username,String password) throws SQLException//添加用户
, NoSuchAlgorithmException
	{
		String encodeoassword =DigestUtil.digestString(password, "SHA");
		String sql ="insert into users values(?,'"  
                + encodeoassword
                + "','SHA',0,NULL,0,null)";
		db1= new db_connection(sql);//创建db_connection对象
		try{
			
			db1.pst.setString(1, username);
            db1.pst.executeUpdate();//执行语句
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
		return true;
	}
}
